<?php
/**
 *
 * 예외처리 기본 클래스
 *
 */

class exceptionBase extends Exception
{
    public function showStackTrace()
    {
        $csUtilStringBuffer = new utilSbuf();
        $csUtilStringBuffer->push('<div style="font-size:12px; margin:5px; background:#f2f2f2; padding:15px; border:2px solid #FF8000;">');
        $csUtilStringBuffer->push('<h3>'.$this->getMessage().'</h3>');

        parse_str($_COOKIE['debug'], $aViewOption);

        if ($aViewOption['sViewTraceFlag'] == 'T') {
            $i = 0;
            foreach ($this->getTrace() as $key => $trace) {
                $csUtilStringBuffer->push($this->showTrace($trace, $i));
                $i++;
            }
        }
        $csUtilStringBuffer->push('</div>');

        return $csUtilStringBuffer->toString();
    }

    private function showTrace($_trace, $_i)
    {
        $html = '<div style="margin-top:15px; font-size:12px;">';
        $html .= '<div style="font-size:12px; font-weight:bold;">'.$_trace['file'].'</div>';
        $html .= '위 파일의 <b style="color:red;">'.$_trace['line'].'</b>번 라인에서 에러가 발생하였습니다.<br />';
        $html .= '</div>';
        return $html;
    }
}
